const express = require('express');
const router = express.Router();
const { sendResponse } = require('@/utils/tool')
const { sendEmailToQQ } = require('@/utils/mail')

/**
 * @swagger
 * /emailToQQ:
 *   post:
 *     summary: 发送邮件
 *     description: 发送邮件到QQ邮箱
 *     tags:
 *       - 邮件
 *     security:
 *       - authorization: []
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               to:
 *                 type: string
 *                 description: 收件人邮箱
 *               subject:
 *                 type: string
 *                 description: 邮件主题
 *               text:
 *                 type: string
 *                 description: 纯文本内容
 *               html:
 *                 type: string
 *                 description: HTML内容(富文本)
 *     responses:
 *       200:
 *         description: 发送邮件成功
 *       429:
 *         description: 频繁发送邮件
 *       400:
 *         $ref: '#/components/responses/paramsBad'
 *       401:
 *         $ref: '#/components/responses/unauthorized'
 *       500:
 *         $ref: '#/components/responses/error'
 */
router.post('/emailToQQ', (req, res) => {
  let { to, subject, text = '', html = '' } = req.body
  const resInfo = sendEmailToQQ(to, subject, text, html)
  sendResponse(req, res, resInfo)
});


module.exports = router;